<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('活动参与人员明细列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">活动编号：</label>
                                <input type="text" name="actId"/>
                            </li>
                            <li>
                                <label style="width: 100px;">代理商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">代理商名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 100px;">活动参与时间：</label>
                                <input type="text" class="time-input"  placeholder="开始时间" name="start"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="end"/>
                            </li>
                            <li>
                                <label style="width: 100px;">参与状态：</label>
                                <select name="status">
                                    <option value="">请选择</option>
                                    <option value="1">开启</option>
                                    <option value="2">关闭</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 10px;"></label>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="addDetails()" shiro:hasPermission="salaryPlan:agentActivityDetails:add">
                    <i class="fa fa-plus"></i> 新增活动人员
                </a>
                <a class="btn btn-success single disabled" onclick="auditInfo()" shiro:hasPermission="salaryPlan:agentActivityDetails:audit">
                    <i class="fa fa-plus"></i> 审核
                </a>
                <a class="btn btn-success single disabled" onclick="sendAudit()" shiro:hasPermission="salaryPlan:agentActivityDetails:sendAudit">
                    <i class="fa fa-plus"></i> 上送审核
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit(null,'700', '1000')" shiro:hasPermission="salaryPlan:agentActivityDetails:edit">
                    <i class="fa fa-edit"></i> 编辑活动人员
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="salaryPlan:agentActivityDetails:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('salaryPlan:agentActivityDetails:edit')}]];
        var removeFlag = [[${@permission.hasPermi('salaryPlan:agentActivityDetails:remove')}]];
        var prefix = ctx + "salaryPlan/agentActivityDetails";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                detailUrl: prefix + "/detail/{id}",
                modalName: "活动参与人员明细",
                firstLoad:false,
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '参与编号'
                },
                {
                    field: 'agentActivity.actName',
                    title: '活动名称'
                },
                {
                    field: 'agentNum',
                    title: '代理商编号'
                },
                {
                    field: 'agentName',
                    title: '代理商名称'
                },
                {
                    field: 'status',
                    title: '参与活动状态',
                    formatter: function (value, row, index) {
                        if (value == 1 ){
                            return '<span style="color: green">开启</span>';
                        } else if(value == 2 ){
                            return '<span style="color: red">关闭</span>';
                        }
                    },
                },
                {
                    field: 'auditStatus',
                    title: '审核状态',
                    formatter: function (value, row, index) {
                        if (value == 0 ){
                            return '<span style="color: blue">未上送</span>';
                        } else if(value == 1 ){
                            return '<span style="color: #23237f">待审核</span>';
                        } else if(value == 2 ){
                            return '<span style="color: green">审核通过</span>';
                        } else if(value == 3 ){
                            return '<span style="color: red">审核打回</span>';
                        }
                    },
                },
                {
                    field: 'levelScope',
                    title: '活动等级'
                },
                {
                    field: 'norm1',
                    title: '考核标准1'
                },
                {
                    field: 'norm2',
                    title: '考核标准2'
                },
                {
                    field: 'award',
                    title: '奖励'
                },
                {
                    field: 'createDate',
                    title: '活动参与时间'
                },
                {
                    field: 'createMan',
                    title: '配置人'
                },
                {
                    field: 'note',
                    title: '备注',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {
                    title: '操作',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.id + '\',\'' + 950 + '\',\'' + 550 + '\')"><i class="fa fa-search"></i>查看详情</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        /**
         * 新增活动人员
         */
        function addDetails() {
            $.modal.open("新增活动人员",prefix + '/addDetails','1000', '700');
        }
        /**
         * 审核参与活动人员
         */
        function auditInfo() {
            var id = $.table.selectColumns('id')[0];
            if ($.common.isEmpty(id)){
                $.modal.alertWarning("请选择一条数据");
                return;
            }
            $.modal.open("审核", prefix + '/auditInfo/' + id,'650','450');
        }


        /**
         * 上送审核
         */
        function sendAudit() {
            var id = $.table.selectColumns('id')[0];
            if ($.common.isEmpty(id)){
                $.modal.alertWarning("请选择一条数据");
                return;
            }
            var data = { "id": id};
            $.modal.confirm("确定要上送审核吗？", function() {
                $.operate.post(prefix + "/sendAudit", data);
            })
        }

    </script>
</body>
</html>